import React, { useReducer } from "react";
import {
  initialState,
  reducer,
  globalContext,
  globalDispatchContext,
} from "../../redux";
/**
 * @description useContext + useReducer
 * @param {Object} props
 * @param {React.ReactNode} props.children
 * @returns {React.JSX.Element}
 */
export const ConsumerProvider = (props) => {
  const [state, dispatch] = useReducer(reducer, initialState);
  return (
    <globalContext.Provider value={state}>
      <globalDispatchContext.Provider value={dispatch}>
        {props.children}
      </globalDispatchContext.Provider>
    </globalContext.Provider>
  );
};
